import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import { resolve } from 'path'
import styleImport from 'vite-plugin-style-import'; // vant按需引入插件

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    styleImport({
      libs: [
        {
          libraryName: 'vant',
          esModule: true,
          resolveStyle: (name) => `vant/es/${name}/style`,
        },
      ],
    })
  ],
  // 配置便捷路径
  resolve: {
    alias: [
      { find: '@', replacement: resolve(__dirname, 'src') },
      { find: '@views', replacement: resolve(__dirname, 'src/views') },
      { find: '@api', replacement: resolve(__dirname, 'src/api') },
      { find: '@utils', replacement: resolve(__dirname, 'src/utils') },
      { find: '@components', replacement: resolve(__dirname, 'src/components') },
      { find: '@style', replacement: resolve(__dirname, 'src/style') },
      { find: '@assets', replacement: resolve(__dirname, 'src/assets') },
      { find: '@router', replacement: resolve(__dirname, 'src/router') },
      { find: '@store', replacement: resolve(__dirname, 'src/store') }
    ]
  },
  server: {
    host: '0.0.0.0'
  }
})
